import axios from '@/api/common.js'
// 实现用户登录
export const login = (data) => {
  return axios({
    method: 'post',
    url: 'login',
    data
  })
}
// 获取用户列表
export const getUserList = (pa) => {
  return axios({
    method: 'get',
    url: 'users',
    params: pa
  })
}
// 添加用户
export const addForm = (data) => {
  return axios({
    method: 'post',
    url: 'users',
    data
  })
}
// 删除数据
export const delUser = (id) => {
  return axios({
    method: 'delete',
    url: `users/${id}`
  })
}
// 修改用户状态
export const upDataUserState = (uid, type) => {
  return axios({
    method: 'put',
    url: `users/${uid}/state/${type}`
  })
}
// 分配角色
export const grantUserRole = (id, rid) => {
  return axios({
    method: 'put',
    url: `users/${id}/role`,
    data: { rid }

  })
}
// 用户编辑
export const editUser = (data) => {
  return axios({
    method: 'put',
    url: `users/${data.id}`,
    data: {
      email: data.email,
      mobile: data.mobile
    }
  })
}
